﻿using System;
using System.Windows;

namespace JHECIS.BLL.Triage.Common
{
    public static class StringResourceHelper
    {
        private static TriageXamlSetting SingleTriageXamlSetting;

        /// <summary>
        /// 获取字符串资源
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetString(string key)
        {
            if (Application.Current.Resources.Contains(key))
            {
                if (Application.Current.Resources[key] is string temp)
                {
                    return temp;
                }
            }
            return string.Empty;
        }
        /// <summary>
        /// 获取分诊xaml中配置
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static TriageXamlSetting GetTriageXamlSetting(string key = "TriageXamlSetting")
        {
            if (SingleTriageXamlSetting == null)
            {
                TriageXamlSetting tempSetting = new TriageXamlSetting();
                try
                {
                    SingleTriageXamlSetting = Newtonsoft.Json.JsonConvert.DeserializeObject<TriageXamlSetting>(GetString(key)) ?? tempSetting;
                }
                catch (Exception)
                {
                    SingleTriageXamlSetting = tempSetting;
                }
            }
            return SingleTriageXamlSetting;
        }
    }

    /// <summary>
    ///xaml中的配置对照实体
    /// </summary>
    public class TriageXamlSetting
    {
        /// <summary>
        /// 计时器是否启用
        /// </summary>
        public bool EisTimerEnable { get; set; } = false;
        /// <summary>
        /// 计时器拉取间隔
        /// </summary>
        public int TimeSpan { get; set; } = 5;
        /// <summary>
        /// 是否打开院前网页
        /// </summary>
        public bool EisWebEnable { get; set; } = false;
        /// <summary>
        /// 计时器拉取间隔
        /// </summary>
        public string EisWebUrl { get; set; } = "http://localhost:8090/";

        /// <summary>
        /// 已存在分诊时的提示方式，0 默认【提示是否新建】 1【天津个性化】
        /// </summary>
        public string ExistTriageQuestion { get; set; } = "0";

        /// <summary>
        /// 分诊患者列表搜索条件是否重置
        /// </summary>
        public bool TriageListReset { get; set; } = true;

    }
}
